import './assets/main.scss'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

import App from './App.vue'
import router from './router'
//全局导入使用axios
import axios from 'axios'

//注册elementplus图标组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import setupPermission from '@/plugins'
//全局组件的导入
import stuSystem from '../src/views/day1211/studemo3.vue';
//导入暗黑模式
import 'element-plus/theme-chalk/dark/css-vars.css'
import { h } from 'vue';
const app = createApp(App)
//注册elementplus图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(createPinia())
app.use(router)
app.use(pinia)
app.mount('#app')
//全局注册组件，下面为链式写法，全局注册了两个组件
// app.component('stuSystem1', {
//   name: 'stuSystem1',
//   render(): unknown {
//     return h('div', [
//       h('h1', '学生管理系统'),
//       h('p', '你好世界'),
//       h('button', { onClick: () => alert('button Clicked!') }, '点我')
//     ])
//   }
// }).component('stuSystem', stuSystem)

app.use(setupPermission)

//将axios挂载到全局
app.config.globalProperties.$axios = axios
app.provide('$axios', axios)
app.use(ElementPlus, {
  locale: zhCn,
})
